package com.xt.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xt.shop.Model.GoodsInfo;
import com.xt.shop.mapper.ShopInfoMapper;
import com.xt.shop.service.GoodsInfoService;
import com.xt.shop.mapper.GoodsInfoMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 24862
* @description 针对表【goods_info】的数据库操作Service实现
* @createDate 2024-01-08 16:00:08
*/
@Service
public class GoodsInfoServiceImpl extends ServiceImpl<GoodsInfoMapper, GoodsInfo>
    implements GoodsInfoService, IService<GoodsInfo> {

    @Resource
    GoodsInfoMapper mapper;

    @Resource
    ShopInfoMapper shopInfoMapper;


    @Override
    public PageInfo<GoodsInfo> queryGoods(int page, int item, String name) {
        PageHelper.startPage(page,item);
        List<GoodsInfo> goodsInfos = mapper.queryByName(name);
        goodsInfos.forEach(el->{
            el.setShopId(shopInfoMapper.selectById(el.getShopId()).getName());
        });
        PageInfo<GoodsInfo> pageInfo=new PageInfo<>(goodsInfos);
        return pageInfo;
    }
}




